package com.chrray.position.controller.web.sysUser;


import com.chrray.position.entity.position.SysUser;
import com.chrray.position.pojo.dto.auth.WebAllUserUpdateRequest;
import com.chrray.position.pojo.dto.util.BaseAllDto;
import com.chrray.position.pojo.dto.auth.LoginDto;
import com.chrray.position.pojo.dto.auth.UpdatePasswordDto;

import com.chrray.position.pojo.vo.auth.LoginVo;
import com.chrray.position.service.auth.MaSysUserService;
import com.chrray.position.util.result.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



/**
 * @author li'miao
 */
@RestController

@RequestMapping("/api/web/sysUser")
@Api(value  = "后台登录接口", tags  = "后台登录接口")
public class LoginController {

    @Autowired
    private MaSysUserService iSysUserService;

   /**
    * 登录接口昵称
    *
    * @param login 登录密码
    * @return
    */
   @ApiOperation(value =  "登录接口/账户设置")
   @RequestMapping(value = "/login", method = RequestMethod.POST)
   @ResponseBody
   public ResponseResult<LoginVo> login(@RequestBody LoginDto login) {
       return iSysUserService.login(login);
   }

    /**
     * 修改自己密码
     *
     * @param dto 修改自己密码
     * @return
     */
    @ApiOperation(value =  "修改自己密码")
    @RequestMapping(value = "/updatePassword", method = RequestMethod.POST)
    @ResponseBody
    public ResponseResult updatePassword(@RequestBody UpdatePasswordDto dto) {
        return iSysUserService.updatePassword(dto);
    }
    @ApiOperation(value =  "查询当前用户信息")
    @RequestMapping(value = "/getSysUser", method = RequestMethod.GET)
    @ResponseBody
    public ResponseResult<SysUser> getSysUser(BaseAllDto login) {
        return iSysUserService.getSysUser(login.getLoginSysUserId());
    }

    @ApiOperation(value =  "修改自己信息")
    @RequestMapping(value = "/updateSysUser", method = RequestMethod.POST)
    @ResponseBody
    public ResponseResult updateSysUser(@RequestBody WebAllUserUpdateRequest sysUser) {
        return iSysUserService.updateSysUser(sysUser);
    }
}
